Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zk-token-sdk] Add VerifyGroupedCiphertext2HandlesValidity and VerifyBatchedGroupedCiphertext2HandlesValidity proof instructions #31816

Merged
merged 5 commits into from
Jun 1, 2023

Conversation

samkim-crypto
Copy link
Contributor

@samkim-crypto samkim-crypto commented May 25, 2023

Problem

The zk-token-proof program does not yet have instructions that can verify whether a ciphertext is valid.

Summary of Changes

Add VerifyGroupedCiphertext2HandlesValidity and VerifyBatchedGroupedCiphertext2HandlesValidity instructions.

The verification for these instructions were benched in a devserver and CU units were computed assuming that 1 CU should take roughly 33ns (as per #25464 (comment)). I hope to create another PR with the benchmark code as a follow-up.

This will be the last set of instructions to be added to the proof program for token-2022.

Fixes #

@samkim-crypto samkim-crypto added the work in progress This isn't quite right yet label May 25, 2023
@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Merging #31816 (08bf5ec) into master (1d6b033) will decrease coverage by 0.1%.
The diff coverage is 80.6%.

@@            Coverage Diff            @@
##           master   #31816     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         757      759      +2     
  Lines      207054   207187    +133     
=========================================
+ Hits       169648   169750    +102     
- Misses      37406    37437     +31     

@mvines mvines added the v1.16 PRs that should be backported to v1.16 label May 30, 2023
@samkim-crypto samkim-crypto changed the title [zk-token-sdk] Add VerifyCiphertextValidity and AggregateCiphertextValidity proof instructions [zk-token-sdk] Add VerifyGroupedCiphertext2HandlesValidity and VerifyBatchedGroupedCiphertext2HandlesValidity proof instructions May 31, 2023
@samkim-crypto samkim-crypto removed the work in progress This isn't quite right yet label May 31, 2023
@CriesofCarrots
Copy link
Contributor

One nit, otherwise looks good to me.
Question, though: Is there a possibility we would ever want to support more than 2 handles? I was idly speculating which things could or should be generic for 2+, but I assume it is not worth the trouble.

@samkim-crypto
Copy link
Contributor Author

Yeah, so that is a good question. The 1 and 3 handle cases are quite natural/useful as well.

For the 1 handle case especially, we would definitely want to support a validity proof for it at some point. The 1 handle grouped ciphertext is just a standard ElGamal, so it could just be CiphertextValidityProof.

For >3 handles, I think it starts becoming much less useful, so it is unlikely we would support it in the future.

It would be really nice to make some of these instructions more generic (if not these instructions, then range proof instructions for different bit-sizes), but it was not clear how since the context and proof sizes are all different. I think it is not out of the question, but I think we would need to use something other than Pod in bytemuck. Probably not worth the trouble at this point as you said...

@samkim-crypto
Copy link
Contributor Author

Oh, and I will also update the names for the sigma proof from CiphertextValidity and AggregatedCiphertextValidity to GroupedCiphertextValidity and BatchedGroupedCiphertextValidity respectively in a follow-up 🙏

@samkim-crypto samkim-crypto merged commit 0495051 into solana-labs:master Jun 1, 2023
mergify bot pushed a commit that referenced this pull request Jun 1, 2023
…ifyBatchedGroupedCiphertext2HandlesValidity` proof instructions (#31816)

* add grouped ciphertext validity proof data

* add batched grouped ciphertext validity proof data

* rename proof contexts and data for consistency

* add grouped ciphertext validity proof instructions

* Update zk-token-sdk/src/instruction/batched_grouped_ciphertext_validity.rs

Co-authored-by: Tyera <[email protected]>

---------

Co-authored-by: Tyera <[email protected]>
(cherry picked from commit 0495051)
samkim-crypto added a commit that referenced this pull request Jun 1, 2023
…nd `VerifyBatchedGroupedCiphertext2HandlesValidity` proof instructions (backport of #31816) (#31918)

[zk-token-sdk] Add `VerifyGroupedCiphertext2HandlesValidity` and `VerifyBatchedGroupedCiphertext2HandlesValidity` proof instructions (#31816)

* add grouped ciphertext validity proof data

* add batched grouped ciphertext validity proof data

* rename proof contexts and data for consistency

* add grouped ciphertext validity proof instructions

* Update zk-token-sdk/src/instruction/batched_grouped_ciphertext_validity.rs

Co-authored-by: Tyera <[email protected]>

---------

Co-authored-by: Tyera <[email protected]>
(cherry picked from commit 0495051)

Co-authored-by: samkim-crypto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.16 PRs that should be backported to v1.16
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants